//
//  TransitionBootcamp_28.swift
//  SwiftUiExercise
//
//  Created by 徐鹏 on 2023/7/2.
//

import SwiftUI

struct TransitionBootcamp_28: View {
    
    @State var showView: Bool = false
    
    var body: some View {
        ZStack(alignment: .bottom){
            
            VStack{
                Button("BUTTON") {
                    showView.toggle()
                }
                Spacer()
                if !showView {
                    RoundedRectangle(cornerRadius: 20)
                        .fill(Color.gray)
                        .frame(height: UIScreen.main.bounds.height * 0.1)
                        .transition(.slide)
                        .animation(.spring())
                    
                    
                    RoundedRectangle(cornerRadius: 20)
                        .fill(Color.green)
                        .frame(height: UIScreen.main.bounds.height * 0.1)
                        .transition(.slide)
                        .animation(.spring())
                    
                    RoundedRectangle(cornerRadius: 20)
                        .fill(Color.green)
                        .frame(height: UIScreen.main.bounds.height * 0.1)
                        .transition(.asymmetric(
                            insertion: .move(edge: .leading),
                            removal: .move(edge: .bottom)))
                        .animation(.spring())
                    
                    RoundedRectangle(cornerRadius: 20)
                        .fill(Color.green)
                        .frame(height: UIScreen.main.bounds.height * 0.1)
                        .transition(.asymmetric(
                            insertion: .move(edge: .bottom),
                            removal: AnyTransition.opacity.animation(.easeInOut)
                         ))
                        .animation(.spring())
                }
            }
            
           
            
           
            
        }
        .edgesIgnoringSafeArea(.bottom)
    }
}

struct TransitionBootcamp_28_Previews: PreviewProvider {
    static var previews: some View {
        TransitionBootcamp_28()
    }
}
